#!/usr/bin/env python
#

import   sys
from form import  *
from PyQt4 import QtCore, QtGui
from lib.data import *
from lib.settings import *

s = Settings()

class testing():
    def SDshowSettings(self):
        self.ui.Name.setText(s.get('Name'))
        self.ui.Surname.setText(s.get('Surname'))
        self.ui.PayModes.setText(s.get('PayModes'))
        self.ui.GreenFormDeadline.setText(s.get('GreenFormDeadline'))
        self.ui.PayDay.setText(s.get('PayDay'))
        self.ui.EventsFile.setText(s.get('EventsFile'))
        self.ui.JobsFile.setText(s.get('JobsFile'))
        self.ui.resetButton.setDisabled(True)
        self.ui.saveButton.setDisabled(False)
    def SDsaveSettings(self):
        s.set('Name', self.ui.Name.text())
        s.set('Surname', self.ui.Surname.text())
        s.set('PayModes', self.ui.PayModes.text())
        s.set('GreenFormDeadline', self.ui.GreenFormDeadline.text())
        s.set('PayDay', self.ui.PayDay.text())
        s.set('EventsFile', self.ui.EventsFile.text())
        s.set('JobsFile', self.ui.JobsFile.text())
        s.save("data/export.cfg")
        self.ui.resetButton.setDisabled(True)
        self.ui.saveButton.setDisabled(True)
    def SDchangedText(self):
        self.ui.resetButton.setDisabled(False)
        self.ui.saveButton.setDisabled(False)

    Settings_Dialog.showSettings = SDshowSettings
    Settings_Dialog.saveSettings = SDsaveSettings
    Settings_Dialog .changedText = SDchangedText

    def MWactionOptions(self):
        self.w = Settings_Dialog()
        #self.w.showSettings()
        self.w.exec_()
        print "options menu"
    def MWgoShiftPage(self):
        self.ui.stackedWidget.setCurrentIndex(0)
        self.ui.calendarWidget.setEnabled(True)
    def MWgoTrainingPage(self):
        self.ui.stackedWidget.setCurrentIndex(1)
        self.ui.calendarWidget.setEnabled(True)
    def MWgoJobsPage(self):
        self.ui.stackedWidget.setCurrentIndex(2)
        self.ui.calendarWidget.setEnabled(False)
    Main_Window.goShiftPage = MWgoShiftPage
    Main_Window.goTrainingPage = MWgoTrainingPage
    Main_Window.goJobsPage = MWgoJobsPage
    
    def main(self): 
        Main_Window.actionOptions = self.MWactionOptions
        print "Starting GUI"
        self.app = QtGui.QApplication(sys.argv) 
        self.MW = Main_Window() 
        self.MW.show()
        sys.exit(self.app.exec_())

if __name__ == "__main__": 
    app = testing()
    app.main()
    #settings_test()
    #html_test()
    #data_test()
    pass

